please write code for it and pass the online judge.
Create a link in your project page naming: 2016Nov30_Major3_ProgrammingTest_YourName
The linked page contains
1. your code
2. a image of your pass test screenshot.
You can refer to this Reference for array manipulation, especially about how to loop an array. http://codingbat.com/doc/java-array-loops.html
The following is an example for loop an array for the maximum value from the reference link.
// Find-Max
// Given a non-empty array of ints, returns
// the largest int value found in the array.
// (does not work with empty arrays)
public int findMax(int[] nums) {
int maxSoFar = nums[0]; // use nums[0] as the max to start
// Look at every element, starting at 1
for (int i=1; i<nums.length; i++) {
if (nums[i] > maxSoFar) {
maxSoFar = nums[i];
}
}
return maxSoFar;
}
Problem A. http://codingbat.com/prob/p194530,
Problem B. http://codingbat.com/prob/p157900
please write code for it and pass the online judge.
Create a link in your project page naming: 2016Nov30_Major3_ProgrammingTest_YourName
The linked page contains
You can refer to this Reference for array manipulation, especially about how to loop an array.
http://codingbat.com/doc/java-array-loops.html
The following is an example for loop an array for the maximum value from the reference link.
// Find-Max // Given a non-empty array of ints, returns // the largest int value found in the array. // (does not work with empty arrays) public int findMax(int[] nums) { int maxSoFar = nums[0]; // use nums[0] as the max to start // Look at every element, starting at 1 for (int i=1; i<nums.length; i++) { if (nums[i] > maxSoFar) { maxSoFar = nums[i]; } } return maxSoFar; }